package me.nereo.multi_image_selector.bean;

import android.support.annotation.NonNull;

/**
 * 图片实体
 * Created by Nereo on 2015/4/7.
 */
public class Image implements Comparable{
    public String path;
    public String name;
    public Long duration;
    public int type;//0代表图片，1代表视频
    public long time;

    public Image(String path, String name, long time){
        this.path = path;
        this.name = name;
        this.time = time;
    }

    public Image(String path, String name, Long duration, int type, long time) {
        this.path = path;
        this.name = name;
        this.duration = duration;
        this.type = type;
        this.time = time;
    }

    @Override
    public boolean equals(Object o) {
        try {
            Image other = (Image) o;
            return this.path.equalsIgnoreCase(other.path);
        }catch (ClassCastException e){
            e.printStackTrace();
        }
        return super.equals(o);
    }

    @Override
    public int compareTo(@NonNull Object o) {
        if (this.time > ((Image) o).time) {
            return 1;
        } else if (this.time < ((Image) o).time) {
            return -1;
        } else {
            return 0;
        }
    }
}
